package com.gw.vip.center.service.dao_service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gw.vip.center.dao.MailSenderInfoMapper;
import com.gw.vip.center.po.MailSenderInfo;
import com.gw.vip.common.exception.ServiceException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * @author GW
 * @description
 * @since 2022-09-26
 */
@Service
public class MailSenderInfoService extends ServiceImpl<MailSenderInfoMapper, MailSenderInfo> {

    public MailSenderInfo getByUserId(String userId) {
        if (StringUtils.isBlank(userId)){
            log.error("userId为空！");
            throw new ServiceException("userId为空！");
        }

        QueryWrapper<MailSenderInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(MailSenderInfo::getUserId, userId);
        return getOne(queryWrapper);
    }
}
